home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: cs.vu.nl!jalten
- From: jalten@cs.vu.nl (Alten JP)
- Subject: Re: Why Do I Use An Ampersand in Member Class Parameters?
- Nntp-Posting-Host: kits.cs.vu.nl
- References: <4emnv2$n5o@alcor.usc.edu> <4enaak$o1h@ubszh.fh.zh.ubs.com> <4ep9do$a31@qualcomm.com>
- Sender: news@cs.vu.nl
- Organization: Fac. Wiskunde & Informatica, VU, Amsterdam
- Date: Thu, 1 Feb 1996 08:27:21 GMT
- X-Newsreader: TIN [version 1.2 PL2]
- Message-ID: <DM38tM.L3G.0.-s@cs.vu.nl>
-
- Nasser Abbasi (nabbasi@qualcomm.com) wrote:
- : In article <4enaak$o1h@ubszh.fh.zh.ubs.com>, jis@ubszh.net.ch says...
- : >
- : >In article <4emnv2$n5o@alcor.usc.edu>, wawda@alcor.usc.edu (Abu Wawda)
- : writes:
- : >|> class Simple
- : >|> {
- : >|> public:
- : >|> Simple();
- : >|> int operator += (const Simple &);
- : >|> private:
- : >|> int data;
- : >|> };
- : >|>
- : >|> I have seen many examples of this but I what I don't understand is
- : why
- : >|> there is an amersand after Simple? I would wind up implementating the
- : >|> function as something like the following:
- : >
- [Flame ignored]
- : >Ian
- [Reflame ignored]
- : Nasser
-
-
- Using the & will pass the object as a reference to the function.
- This way not the whole object needs to be pushed on the stack,
- but just the pointer, while you can pretend you have the object,
- not the pointer.
-
- the keywork is _reference_
-
- Jelle Paul
-
- --
- +-------------------------------------------------------+
- | Jelle Paul Alten | jalten@cs.vu.nl |
- | Vrije Universiteit Amsterdam | |
- +-------------------------------------------------------+
-